package com.ccy.assist;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Decorator for {@link InputStream}. Provides possibility to return defined stream length by
 * {@link #available()} method
 */
public class ContentLengthInputStream extends FilterInputStream {

	private final int mLength;

	public ContentLengthInputStream(InputStream in, int length) {
		super(in);
		this.mLength = length;
	}

	@Override
	public int available() throws IOException {
		return mLength;
	}
}